#ifndef __DSP_SOFTWAREUART_H_
#define __DSP_SOFTWAREUART_H_

#include "stm32f1xx_hal.h"
#include "main.h"

#define RX_Buffer_Len  	128
#define TX_Buffer_Len 	128

extern uint8_t Uart_Status;
#define 	Uart_Sending 	0x01
#define 	Uart_Tx_Wait 	0x02
#define 	Uart_receing 	0x04
#define 	Uart_Rx_ORFT 	0x08
#define 	Uart_Rx_Wait 	0x10
#define 	Reading_Temp 	0x20

#define 	Successed 	0x00
#define 	Time_out 		0x01

extern uint8_t Uart_Bit_Cnt;
extern uint32_t Last_Rec_time;

extern uint8_t RX_Buffer[RX_Buffer_Len];
extern uint8_t TX_Buffer[TX_Buffer_Len];

extern uint8_t RX_Uart_Pointer;
extern uint8_t TX_Uart_Pointer;
extern uint8_t TX_Uart_Data_Len;

extern TIM_HandleTypeDef htim2;
extern UART_HandleTypeDef huart2;
extern DMA_HandleTypeDef hdma_usart2_rx;
extern DMA_HandleTypeDef hdma_usart2_tx;

uint8_t Sofware_Uart_Send(uint8_t *L_Data, uint8_t Length, uint8_t timeout);
void COM_SET_OUTPUT(void);
void COM_SET_INPUT(void);
void Write_Bit(void);
void Read_Bit(void);
#endif
